# 发送邮件
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr

print("-" * 50, "发送邮件", "-" * 50)
# 构建文件内容
msg = MIMEText("利用python发送邮件学习测试", "html", "utf-8")
name = "丁知文"
from_email = "skya.cool@163.com"
to_email = "1134142584@qq.com"
# 授权码
sqm = "FSMDWAYOQCWMOAHY"

# 自己的名字和邮箱
msg["From"] = formataddr([name, from_email])
# 目标邮箱
msg["to"] = to_email
# 主题
msg["Subject"] = "发送邮件测试1"

# 发送邮件
server = smtplib.SMTP_SSL("smtp.163.com")
# 账户和授权码
server.login(from_email, sqm)
# 自己的邮箱、目标邮箱、内容
server.sendmail(from_email, to_email, msg.as_string())
server.quit()
print("发送完毕")